package com.lanou.projecta_163news.fragment;

import android.graphics.Color;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.ViewGroup;

import com.lanou.projecta_163news.base.BaseFragment;
import com.lanou.projecta_163news.adapter.MainAdapter.MainFragmentTabAdapter;
import com.lanou.projecta_163news.fragment.newsFragment.CountryFragment;
import com.lanou.projecta_163news.fragment.newsFragment.ElectronicsFragment;
import com.lanou.projecta_163news.fragment.newsFragment.GameFragment;
import com.lanou.projecta_163news.fragment.newsFragment.NewsFragment;
import com.lanou.projecta_163news.fragment.newsFragment.RecreationFragment;
import com.lanou.projecta_163news.fragment.newsFragment.SportsFragment;
import com.lanou.projecta_163news.fragment.newsFragment.WarFragment;
import com.lanou.projecta_163news.R;

import java.util.ArrayList;

/**
 * Created by dllo on 16/3/5.
 */
public class MainFragment extends BaseFragment {
    private TabLayout mainFragmentTL;
    private ViewPager mainFragmentVP;
    private ArrayList<Fragment> maFrData;
    private MainFragmentTabAdapter mainFragmentTabAdapter;


    @Override
    protected void initView() {
        mainFragmentTL = bindView(R.id.main_tablayout);
        mainFragmentVP = bindView(R.id.main_viewpager);

    }

    //"实时","国家","军事","娱乐","科技","游戏","体育"
    @Override
    protected void initData() {
        maFrData = new ArrayList<>();
        maFrData.add(new NewsFragment());
        maFrData.add(new CountryFragment());
        maFrData.add(new WarFragment());
        maFrData.add(new RecreationFragment());
        maFrData.add(new ElectronicsFragment());
        maFrData.add(new GameFragment());
        maFrData.add(new SportsFragment());
        mainFragmentTabAdapter = new MainFragmentTabAdapter(getChildFragmentManager(), maFrData);
        mainFragmentVP.setAdapter(mainFragmentTabAdapter);

        mainFragmentTL.setTabTextColors(Color.BLACK, Color.DKGRAY);
        mainFragmentTL.setSelectedTabIndicatorColor(Color.LTGRAY);

        mainFragmentTL.setTabMode(TabLayout.MODE_SCROLLABLE);
        mainFragmentTL.setupWithViewPager(mainFragmentVP);


    }

    @Override
    protected int getLayout() {
        return R.layout.fragment_main;
    }

    @Override
    protected ViewGroup getNull() {
        return null;
    }
}
